package cn.xhjava.crm.workbench.service.impl;

import cn.xhjava.crm.workbench.domain.ActivityRemark;
import cn.xhjava.crm.workbench.mapper.ActivityRemarkMapper;
import cn.xhjava.crm.workbench.service.ActivityRemarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author:   XiaHu
 * Date:     2023/6/27
 */
@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {
    @Autowired
    private ActivityRemarkMapper activityRemarkMapper;

    @Override
    public List<ActivityRemark> selectActivityRemarkByActivityId(String id) throws Exception {
        return activityRemarkMapper.selectActivityRemarkByActivityId(id);
    }

    @Override
    public int add(ActivityRemark remark) throws Exception {
        return activityRemarkMapper.insert(remark);
    }

    @Override
    public int delete(String id) throws Exception {
        return activityRemarkMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(ActivityRemark remark) throws Exception {
        //1、获取activity_id
        ActivityRemark activityRemark = activityRemarkMapper.selectByPrimaryKey(remark.getId());
        remark.setActivityId(activityRemark.getActivityId());
        return activityRemarkMapper.updateByPrimaryKeySelective(remark);
    }
}
